﻿using System.Data.Services;
using System.Data.Services.Common;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Web;

namespace NextCommerce.Web.OData {

	/* [JavascriptCallbackBehavior] */
	[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
	public class CategoriesService : DataService<CategoriesContext> {

		public static void InitializeService(DataServiceConfiguration config) {
			config.UseVerboseErrors = true;
			config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
			config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
			config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
		}

		/* [MimeType("text/html")] */
		[SingleResult]
		[WebGet]
		public Category GetFirst() {
			return Category.GetAll().First();
		}

	}
}
